<template>
  <div class="index">
    <div class="center">
      <left></left>
      <div class="right">
        <top></top>
        <div class="hei10"></div>

        <div class="team" v-if="$route.path!='/zhanghuguanli/quanxianguanli'">
          <div class="powertop">
            <router-link class="powertopli" to="/zhanghuguanli/wodetuandui">我的团队</router-link>
            <router-link class="powertopli" to="/zhanghuguanli/gangweiguanli">岗位管理</router-link>
            <router-link v-if="memid == 50481 || memid == 304676 || memid == 304672" class="powertopli" to="/zhanghuguanli/gongnengdingyi">功能定义</router-link>
            <router-link v-if="memid == 50481 || memid == 304676 || memid == 304672" class="powertopli" to="/zhanghuguanli/api">API定义</router-link>

<!-- 						<router-link class="powertopli" to="/fabuxitongtongzhi" v-if="shopid == 50481 || shopid == 304676">发布系统更新</router-link>
            <router-link class="powertopli" to="/xitongtongzhi">系统更新</router-link> -->
          </div>
        </div>
        <keep-alive :include="includsname">
        <router-view></router-view>

        </keep-alive>
      </div>
    </div>
    <!-- <foot></foot> -->
  </div>
</template>

<script>
  import axios from "axios";
  import top from '@/components/top.vue'
  import left from '@/components/left.vue'
  import foot from "@/components/foot.vue"
  export default {
    components: {
      "left": left,
      "top": top,
      "foot": foot
    },
    name: 'zhanghuguanli',
    data() {
      return {
        memid:"",
        includsname:[],
      shopid:''
      }
    },
    created() {
      var shop = JSON.parse(localStorage.getItem('USER'));
      this.memid = shop.id

      if(shop.functions.filter(item=>item.code == 'F01') == ''){
        window.history.back();
      }


      var that = this
    this.shopid = JSON.parse(localStorage.getItem('SHOP')).shop_id

    var namearr = []
    var getarr = JSON.parse(localStorage.getItem('LOCAL_NAV'+this.shopid))
    for(var x = 0;x<getarr.length;x++){
      namearr.push(getarr[x].name1)
      if(getarr[x].name2!=''){
        namearr.push(getarr[x].name2)
      }
    }
    that.includsname = namearr
    },
    mounted(){

      var that = this

      // 监听localhostStorage的数据变化，结合utils/tool.js配合使用
      window.addEventListener('setItemEvent', function(e) {
        var namearr = []
        if(e.key == 'LOCAL_NAV'+that.shopid){
          var getarr = JSON.parse(e.newValue)
          for(var x = 0;x<getarr.length;x++){
            namearr.push(getarr[x].name1)
            if(getarr[x].name2!=''){
              namearr.push(getarr[x].name2)
            }
          }
          that.includsname = namearr
          // console.log('namearr——app')
          // console.log(that.includsname)
        }



      })
    },
  }
</script>

<style lang="scss" scoped>
  .team {
  	background: #F9F9F9;
  }

  .powertop {
  	display: flex;
  	background:#f9f9f9;
  }

  .powertopli {
  	flex-basis: 180px;
  	line-height: 50px;
  	border-bottom: 3px #F9F9F9 solid;
  	color: #727272;
  	border-right: 1px #F9F9F9 solid;
  	font-size: 16px;
  	text-align: center;
  }

  .router-link-active {
  	background: #FFFFFF;
  	border-bottom: 3px #2974FF solid;
  }


</style>
